package com.zp95sky.demo.aidemo.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.zp95sky.demo.aidemo.biz.TextProcessingBiz;
import com.zp95sky.demo.aidemo.common.response.BaseResponse;
import com.zp95sky.demo.aidemo.domain.ProcessTextResultDo;
import com.zp95sky.demo.aidemo.dto.ProcessTextAsyncDto;
import com.zp95sky.demo.aidemo.dto.TextResultQueryDto;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文本处理接口
 */
@RestController
@RequestMapping("/text")
@RequiredArgsConstructor
public class TextProcessingController {

    private final TextProcessingBiz textProcessingBiz;

    /**
     * 异步处理文本
     * @param asyncDto 文本处理请求参数
     * @return 任务ID
     */
    @PostMapping("/async")
    public BaseResponse<String> processTextAsync(@RequestBody ProcessTextAsyncDto asyncDto) {
        return textProcessingBiz.processTextAsync(asyncDto);
    }

    /**
     * 查询处理结果
     * @param queryDto 任务ID
     * @return 任务结果
     */
    @PostMapping("/result/query")
    public BaseResponse<ProcessTextResultDo> textResultQuery(@RequestBody TextResultQueryDto queryDto) throws JsonProcessingException {
        return textProcessingBiz.textResultQuery(queryDto);
    }

}
